package com.joysuch.wwyt.bp.controller;

import com.joysuch.wwyt.bp.bean.investigate.BpSafeTableTypeBean;
import com.joysuch.wwyt.bp.service.BpSafeTableTypeService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author ZhangDong
 * @Date 2020/12/1 15:07
 */
@RestController
@RequestMapping("bp/table/type")
@Api(tags = "bp/table/type 安全排查表类型")
public class BpSafeTableTypeController {

    @Autowired
    private BpSafeTableTypeService tableTypeService;

    @PostMapping("save")
    @ApiOperation("安全排查表类型--新增/修改")
    @RequiresPermissions("bp-table-type:save")
    public ResultBean save(@Valid @RequestBody BpSafeTableTypeBean bean) {
        return tableTypeService.save(bean);
    }

    @GetMapping("tree")
    @ApiOperation("左侧树状显示-2层结构")
    public ResultBean tree() {
        return tableTypeService.tree();
    }

    @GetMapping("delete")
    @ApiOperation("安全排查表类型--删除")
    @RequiresPermissions("bp-table-type:delete")
    public ResultBean delete(Long id) {
        return tableTypeService.delete(id);
    }

    @GetMapping("allType")
    @ApiOperation("获取所有排查表类型")
    public ResultBean allType() {
        return tableTypeService.allType();
    }

    @GetMapping("getAllChild")
    @ApiOperation("获取所有2级类型--全部时不用传值")
    public ResultBean getAllChild(Long typeId) {
        return tableTypeService.getAllChild(typeId);
    }

}
